/*
 * generate by table-builder.Don't modify it
 */
using IQIGame.Onigao.Framework.Serialization;
using IQIGame.Onigao.GamePlay;
using System.Collections.Generic;


namespace CfgTable
{
    public partial class TbCfgEquipSkin
    {
        private readonly Dictionary<int, CfgEquipSkin> _dataMap;
        private readonly List<CfgEquipSkin> _dataList;

        /// <summary>
        /// 按ItemId作为key的id列表
        /// </summary>
        public IReadOnlyDictionary<int, IReadOnlyList<int>> itemIdList { get; private set; }

        public TbCfgEquipSkin(ByteBuf _buf)
        {
            //first read common data
            _TbCommonEquipSkin _commonData = null;
            var commonSize = _buf.ReadSize();
            if (commonSize > 0)
            {
                _commonData = new _TbCommonEquipSkin(_buf);
            }

            //then read row data
            var size = _buf.ReadSize();
            _dataMap = new Dictionary<int, CfgEquipSkin>(size * 3 / 2);
            _dataList = new List<CfgEquipSkin>(size);

            for (int i = 0; i < size; i++)
            {
                CfgEquipSkin _v;
                _v = CfgEquipSkin.DeserializeCfgEquipSkin(_buf, _commonData);
                _dataList.Add(_v);
                _dataMap.Add(_v.Id, _v);
            }

            // read extra fields 
            { int __n0 = _buf.ReadSize(); var __f0 = new Dictionary<int, IReadOnlyList<int>> (__n0 * 3 / 2); itemIdList = __f0 ; for (var __i0 = 0 ; __i0 < __n0 ; __i0++ ) { int __k0; __k0 = _buf.ReadInt(); IReadOnlyList<int> __v0; { int __n1 = _buf.ReadSize(); var __f1 = new int[__n1]; __v0 = __f1; for (var __i1 = 0 ; __i1 < __n1 ; __i1++ ){ int __v1; __v1 = _buf.ReadInt(); __f1[__i1] = __v1;} } __f0.Add(__k0, __v0); } }

            PostInit();
        }

        public IReadOnlyDictionary<int, CfgEquipSkin> DataMap => _dataMap;
        public IReadOnlyList<CfgEquipSkin> DataList => _dataList;

        public CfgEquipSkin Get(int key)
        {
            if (_dataMap.TryGetValue(key, out var v))
            {
                return v;
            }
            IQIGame.Onigao.Framework.LogGame.LogError("[TbCfgEquipSkin] config not found,id:" + key.ToString());

            return null;
        }

        public CfgEquipSkin GetWithoutError(int key) => _dataMap.TryGetValue(key, out var v) ? v : null;

        /// <summary>
        /// table data file
        /// </summary>
        public static string TableFileName { get; } = "equipskin";

        /// <summary>
        /// load table function
        /// </summary>
        public static TbCfgEquipSkin LoadFromFunc(System.Func<string, ByteBuf> loadFunc)
        {
            return new TbCfgEquipSkin(loadFunc(TableFileName));
        }

        /// <summary>
        /// post process table
        /// </summary>
        partial void PostInit();

    }

    public partial class CfgEquipSkin
    {
        private CfgEquipSkin(ByteBuf _buf, _TbCommonEquipSkin _commonData)
        {
            Id = _buf.ReadInt();
            Name = TableCenter.GetI18NText(_buf.ReadInt());
            Describe = TableCenter.GetI18NText(_buf.ReadInt());
            ItemId = _buf.ReadInt();
            { int dataIndex = _buf.ReadInt() - 1; Icon = _commonData._field0[dataIndex]; }
            { int dataIndex = _buf.ReadInt() - 1; Card = _commonData._field1[dataIndex]; }
            IsLockShow = _buf.ReadBool();
            { int dataIndex = _buf.ReadInt() - 1; AttTypes = _commonData._field2[dataIndex]; }
            { int dataIndex = _buf.ReadInt() - 1; AttValues = _commonData._field3[dataIndex]; }

            PostInit();
        }

        internal static CfgEquipSkin DeserializeCfgEquipSkin(ByteBuf _buf, _TbCommonEquipSkin _commonData)
        {
            return new CfgEquipSkin(_buf, _commonData);
        }

        /// <summary>
        /// major key
        /// </summary>
        public int Id { get; private set; }

        /// <summary>
        /// 名称文本
        /// </summary>
        public string Name { get; private set; }
        /// <summary>
        /// 描述文本
        /// </summary>
        public string Describe { get; private set; }
        /// <summary>
        /// 装备id
        /// </summary>
        public int ItemId { get; private set; }
        /// <summary>
        /// Icon图片
        /// </summary>
        public string Icon { get; private set; }
        /// <summary>
        /// 卡面图片
        /// </summary>
        public string Card { get; private set; }
        /// <summary>
        /// 未解锁是否显示
        /// </summary>
        public bool IsLockShow { get; private set; }
        /// <summary>
        /// 基础加成-类型
        /// </summary>
        public IReadOnlyList<int> AttTypes { get; private set; }
        /// <summary>
        /// 基础加成-值
        /// </summary>
        public IReadOnlyList<int> AttValues { get; private set; }

        /// <summary>
        /// Icon资源全路径
        /// </summary>
        public string Icon_fullPath => $"Res/05_Images/Sprite/{Icon}";
        /// <summary>
        /// Card资源全路径
        /// </summary>
        public string Card_fullPath => $"Res/05_Images/Texture/{Card}";

        /// <summary>
        /// post process table
        /// </summary>
        partial void PostInit();
    }

    /// <summary>
    /// internal common data.Optimize memory
    /// </summary>
    internal class _TbCommonEquipSkin
    {

        internal IReadOnlyList<string> _field0 { get; private set; }
        internal IReadOnlyList<string> _field1 { get; private set; }
        internal IReadOnlyList<IReadOnlyList<int>> _field2 { get; private set; }
        internal IReadOnlyList<IReadOnlyList<int>> _field3 { get; private set; }
        internal _TbCommonEquipSkin(ByteBuf _buf)
        {
            { int __n0 = _buf.ReadSize(); var __f0 = new string[__n0]; _field0 = __f0; for (var __i0 = 0 ; __i0 < __n0 ; __i0++ ){ string __v0; __v0 = _buf.ReadString(); __f0[__i0] = __v0;} }
            { int __n0 = _buf.ReadSize(); var __f0 = new string[__n0]; _field1 = __f0; for (var __i0 = 0 ; __i0 < __n0 ; __i0++ ){ string __v0; __v0 = _buf.ReadString(); __f0[__i0] = __v0;} }
            { int __n0 = _buf.ReadSize(); var __f0 = new int[__n0][]; _field2 = __f0; for (var __i0 = 0 ; __i0 < __n0 ; __i0++ ){ int[] __v0; { int __n1 = _buf.ReadSize(); var __f1 = new int[__n1]; __v0 = __f1; for (var __i1 = 0 ; __i1 < __n1 ; __i1++ ){ int __v1; __v1 = _buf.ReadInt(); __f1[__i1] = __v1;} } __f0[__i0] = __v0;} }
            { int __n0 = _buf.ReadSize(); var __f0 = new int[__n0][]; _field3 = __f0; for (var __i0 = 0 ; __i0 < __n0 ; __i0++ ){ int[] __v0; { int __n1 = _buf.ReadSize(); var __f1 = new int[__n1]; __v0 = __f1; for (var __i1 = 0 ; __i1 < __n1 ; __i1++ ){ int __v1; __v1 = _buf.ReadInt(); __f1[__i1] = __v1;} } __f0[__i0] = __v0;} }
        }

    }
}
